package com.itfly.mapper;

import com.itfly.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProductMapper {
    //新增
    @Insert("insert into  t_product(pname,pno,pitem,punit,price,image) " +
            "values(#{pname},#{pno},#{pitem},#{punit},#{price},#{image})")
    int insertOne(Product product);

    //根据pno查询商品
    @Select("select * from t_product where pno=#{pno}")
    Product selectByPno(String pno);
    //查询所有商品
    @Select("select * from t_product ")
    List<Product> selectAll();
    //删除
    @Delete("delete from t_product where pno = #{pno}")
    int deleteByPno(String pno);

    @Update("UPDATE t_product SET pname = #{pname}, pitem = #{pitem}, punit = #{punit}, price = #{price},image=#{image} WHERE pno = #{pno}")
    void updateAll(Product product);
}